package cn.edu.neu.lab603.cloudeval.strategy.policy

import cn.edu.neu.lab603.cloudeval.entity.{DataCenter, PhysicalMachine => Host, VirtualMachine => VM}

/** 实现最小迁移次数的虚拟机选择策略。
  *
  * Created by yfwz100 on 2016/11/9.
  */
class VMSelectionPolicyMinimumMigrationTime extends VMSelectionPolicy {

  import MigrationDef._

  override def getVMFromMigratedHost(host: Host)(implicit dataCenter: DataCenter): Iterable[VM] = {
    val vms = host.getMigratableVMs
    if (vms.nonEmpty) {
      Seq(host.getMigratableVMs.minBy(_.getSpecResMap("ram")))
    } else {
      Seq.empty
    }
  }

  override def toString: String = "MMT"
}
